var optionFormatter = function(value, row, index) {
	return `<div class="dropdown">
  <button class="btn btn-outline-primary btn-block dropdown-toggle" type="button" data-toggle="dropdown">
    操作
  </button>
  <div class="dropdown-menu dropdown-menu-right">
    <a class="dropdown-item" target="_blank"  href="news-${value}.htm">查看</a>
  </div>
</div>`;
}

var indexFormatter = function(value, row, index) {
	return index + 1;
}

var moneyFormatter = function(v){
	try{
		return `<b class="text-danger">￥${v.toFixed(2)}</b>`;
	}catch(e){
		return "-";
	}
}

var lookFormatter = function(v,r,i) {
	return `<a target="_blank" href="user/order-look.jsp?id=${v}">查看</a>`;
}

var payFormatter = function(v,r,i) {
	return `<a target="_blank" href="user/order-pay.let?id=${v}">继续支付</a>`;
}

var checkFormatter = function(v,r,i) {
	return `<a href="javascript:check(${v});" class="text-success"><strong>签收</strong></a>`;
}
var notcheckFormatter = function(v,r,i) {
	return `<a href="javascript:notcheck(${v});" class="text-danger">拒收</a>`;
}

var datagrid = $("._datagrid");//分页表格

var status = new URLSearchParams(location.search).get("status");//从访问地址中获取的类型父id

datagrid.find("._"+status).remove();

/**
	初始化数据表格w
 */
var initTable = ()=>{
	datagrid.bootstrapTable({
		url: "user/order.let?status="+status,
		dataField: "list",//rows
		totalField: "total",
		queryParamsType: "",//limit
		pagination: true,
		sidePagination: "server"
	});
}


initTable();

//_delete
datagrid.on("click", "._delete", function()  {
	let row = datagrid.bootstrapTable("getData")[$(this).data("index")];
	console.info(row);
	let articleId = row.articleId;
	sys.confirm("您确定要删除这条记录吗？", function(r) {
		if (r) {
			$.post(
				"admin/article.let?action=delete",
				{ "articleId": articleId },
				function(data) {
					if (data.code == 200) {
						sys.toastr.success("删除成功");
						datagrid.bootstrapTable("refresh");
					} else {
						sys.toastr.error(data.message);
					}
				}, "json"
			);

		}
	});

});
